package com.leixin.demo.service.impl;

import com.leixin.demo.dao.UserDao;
import com.leixin.demo.entity.UserEntity;
import com.leixin.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    UserDao userDao;
    @Autowired
    RedisTemplate redisTemplate;
    @Override
    public UserEntity queryUserById(String id) {

        return userDao.queryUserById(id);
    }

    @Override
    public void addUser(UserEntity userEntity) {
        redisTemplate.opsForValue().set(userEntity.getId(),userEntity);
        userDao.addUser(userEntity);
    }
}
